﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dukou.Search
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class DictionarySearchResultItem : AbstractSearchResultItem
    {
        private IDictionary<string, object> m_dic;

        public DictionarySearchResultItem()
            : this(new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase))
        {
        }

        public DictionarySearchResultItem(IDictionary<string, object> dic)
        {
            this.m_dic = dic;
        }

        /// <summary>
        /// 
        /// </summary>
        public override object UnderlayerObject
        {
            get 
            { 
                return this.m_dic; 
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public override IEnumerable<string> FieldNames
        {
            get
            {
                return this.m_dic.Keys;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public override object GetValue(string fieldName)
        {
            object returnValue = null;
            this.m_dic.TryGetValue(fieldName, out returnValue);
            return returnValue;
        }
    }
}
